package com.cardone.platform.configuration.validator;

import lombok.NonNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.cardone.platform.configuration.dto.DictionaryDto;
import com.cardone.platform.configuration.service.ConfigurationService;

/**
 * 字典
 * 
 * @author yaoht
 * 
 */
@Component(DictionaryValidator.BEAN_ID)
public class DictionaryValidator implements Validator {
	/**
	 * spring bean id
	 */
	public static final String BEAN_ID = "com.cardone.platform.configuration.validator.DictionaryValidator";

	/**
	 * 站服务
	 */
	@Qualifier(ConfigurationService.BEAN_ID)
	@Autowired(required = false)
	private ConfigurationService configurationService;

	@Override
	public boolean supports(@NonNull final Class<?> clazz) {
		return DictionaryDto.class.equals(clazz);
	}

	@Override
	public void validate(@NonNull final Object target, @NonNull final Errors errors) {
		// DictionaryDto dictionary = (DictionaryDto) target;
		//
		// if (StringUtils.isBlank(dictionary.getCode())) {
		// errors.reject("dictionary.code.required", "编号不能为空");
		// }
	}
}
